Skip to content

Conversation

@hodgesds
Copy link

Implements a Model Context Protocol (MCP) server that allows AI agents to interact with Buck2 through a JSON-RPC interface over stdio. Features:

  • MCP protocol implementation with JSON-RPC 2.0 transport
  • Daemon client for connecting to running Buck2 daemon
  • Tools: buck2_build, buck2_query (cquery/uquery), buck2_targets
  • Async build support with operation polling for long-running builds
  • Operation manager for tracking and cancelling async operations

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 11, 2026
@hodgesds
Copy link
Author

Example from Claude code:

❯ claude

╭─── Claude Code v2.1.4 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                     │ Tips for getting started                                                                                                               │
│                Welcome back Daniel!                 │ Run /init to create a CLAUDE.md file with instructions for Claude                                                                      │
│                                                     │                                                                                                                                        │
│                                                     │ ─────────────────────────────────────────────────────────────────                                                                      │
│                       ▐▛███▜▌                       │ Recent activity                                                                                                                        │
│                      ▝▜█████▛▘                      │ No recent activity                                                                                                                     │
│                        ▘▘ ▝▝                        │                                                                                                                                        │
│    Sonnet 4.5 · Claude Max ·                        │                                                                                                                                        │
│    hodgesds Organization                            │                                                                                                                                        │
│                    ~/git/buck2                      │                                                                                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

❯ /mcp
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ query (buck2)                                                                                                                                                                                │
│                                                                                                                                                                                              │
│ Tool name: query                                                                                                                                                                             │
│ Full name: mcp__buck2__query                                                                                                                                                                 │
│                                                                                                                                                                                              │
│ Description:                                                                                                                                                                                 │
│ Run cquery or uquery on the Buck2 target graph. cquery operates on the configured target graph (with resolved selects), uquery operates on the unconfigured graph.                           │
│                                                                                                                                                                                              │
│ Parameters:                                                                                                                                                                                  │
│   • output_attributes: array - Attributes to include in output (e.g., ['name', 'deps', 'srcs'])                                                                                              │
│   • query (required): string - The query expression (e.g., 'deps(//foo:bar)', 'rdeps(//..., //foo:bar)')                                                                                     │
│   • query_type: string - Type of query: cquery (configured) or uquery (unconfigured)                                                                                                         │
│   • target_platform: string - Target platform for configuration (cquery only)                                                                                                                │
│   • target_universe: array - Target universe to limit query scope (cquery only)     

@meta-codesync
Copy link
Contributor

meta-codesync bot commented Jan 11, 2026

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D90469508. (Because this pull request was imported automatically, there will not be any future comments.)

@hodgesds hodgesds force-pushed the buck-mcp branch 2 times, most recently from 230f742 to b4cfb44 Compare January 15, 2026 14:50
Implements a Model Context Protocol (MCP) server that allows AI agents
to interact with Buck2 through a JSON-RPC interface over stdio. Features:

- MCP protocol implementation with JSON-RPC 2.0 transport
- Daemon client for connecting to running Buck2 daemon
- Tools: buck2_build, buck2_query (cquery/uquery), buck2_targets
- Async build support with operation polling for long-running builds
- Operation manager for tracking and cancelling async operations

Signed-off-by: Daniel Hodges <hodgesd@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant